<template>
<!-- 这是支付成功的页面 -->
  <div id="paymentS">
    <el-container>
      <el-header><paymentTitleBar :payTitle="payTitle"></paymentTitleBar></el-header>
      <el-main>
        <div class="success" v-if="successBool">
          <div class="success_img">
            <i class="img_icon el-icon-check"></i><h2>{{$t("paymentSuccessful.success")}}</h2>
          </div>
          <div class="orders">
            <div class="orderTitle">{{$t("orderDetails.orderNumber")}}：</div>
            <div class="orderNum" v-for="item in ordersn" :key="item">
              <p>{{item}}</p>
            </div>
          </div>
          <div>{{$t("paymentSuccessful.total")}}：{{total_fee}}元</div>
          <div>{{$t("paymentSuccessful.time")}}</div>
          <div class="success_a"><router-link to="/accountInformation/myorder">{{$t("paymentSuccessful.see")}}</router-link><i class="text_i"></i><router-link to="/">{{$t("payment.home")}}</router-link></div>
        </div>
        <div class="error" v-else>
          <h3>{{$t("paymentSuccessful.noPayment")}}</h3>
          <div><router-link to="/">{{$t("payment.home")}}</router-link><i class="text_i"></i><router-link to="/shopping"> {{$t("Transport.return")}}</router-link></div>
        </div>
      </el-main>
      <el-footer><Footer></Footer></el-footer>
    </el-container>
    
    
  </div>
</template>

<script>
import paymentTitleBar from '@/components/PaymentTitleBar';
import Footer from "@/components/Footer.vue";
export default {
  data () {
    return {
      payTitle: {title: this.$t("paymentSuccessful.success"), id:"paymentS"}, // 头部标题
      successBool: true,  // 是否显示支付成功
      total_fee: "",    // 订单总价
      ordersn: "",    // 订单号
    }
  },
  components: {
    paymentTitleBar,
    Footer
  },
  created () {
    // var _this = this;
    let PSLists = this.$store.state.PSList;
    this.total_fee = PSLists.total_fee;
    let arr = PSLists.ordersn.split(',');
    for (let i = 0; i < arr.length; i++) {
      // 判断，拿数组第一个值时，不和自身对比，所以下面要+1，进行下一位对比
      for (let j = i+1; j < arr.length; j++) {
        if(arr[i] == arr[j]) {
          // 有相同的就删掉
          arr.splice(j,1);
          j--;
        }
        
      }
    }
    this.ordersn = arr;
    // _this.$store.commit('paymentSuccessList', {});  // 清空支付数据
  }
}
</script>

<style lang="less" scoped>
.el-header {
    background-color: white!important;
}
.el-header, .el-footer {
  color: #333;
  text-align: center;
  height: auto!important;
  padding: 0px;
}
.el-main {
  color: #333;
  text-align: center;
  padding: 40px 80px;
  // 计算减去头部和底部的高度，就是中间的高度
  min-height: calc(100vh - 96px - 220px);
  min-width: 1350px;
}
.success {
  width: 500px;
  text-align: left;
  margin: auto;
  line-height: 30px;
  font-size: 15px;
  
}
.success_a {
  margin-top: 30px;
  font-size: 18px;
}
a {
  text-decoration: none;
  // margin-right: 10px;
}
a:hover {
  text-decoration: none;
}
.text_i {
  width: 25px;
  display: inline-block;
}
.success_img {
  position: relative;
  padding: 20px;
  margin-top: 10px;
  .img_icon {
    font-size: 40px;
    position: absolute;
    color: #83c44e;
    top: 5px;
    left: 0px;
    width: 50px;
    height: 50px;
    text-align: center;
    line-height: 45px;
    border: 2px solid #83c44e;
    border-radius: 50%;
  }
  h2 {
    text-transform: none;
    margin: 0px 0px 30px 55px;
    color:  #83c44e;
  }
}
.orders {
  margin-bottom: 10px;
  // .orderTitle {
  //   display: inline-block;
  // }
  .orderNum {
    // display: inline-block;
    p {
      display: block;
      margin: 0px;
    }
  }
  
}

</style>